if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_ThanhVien_UpdateInfo]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_ThanhVien_UpdateInfo]
go

create proc [sp_ThanhVien_UpdateInfo]
	@MaThanhVien	int , 
	@HoTen			nvarchar(50),
	@DiaChi			nvarchar(100),
	@DienThoai		varchar(40),
	@Email			varchar(40),
	@BangCap		varchar(40),
	@NgaySinh		datetime,
	@TinhTrang		int ,
	@MaChiNhanh		int,
	@MaVaiTro		int
as
Begin 
	Begin
	update ChiTietThanhVien
	set 
		Ho_ten=@HoTen,
		Dia_chi=@DiaChi,
		tel=@DienThoai,
		email=@Email,
		Bang_cap=@BangCap,
		Ngay_sinh=@NgaySinh,
		tinh_trang=@TinhTrang
	where Ma_thanh_vien = @MaThanhVien
	End

	Begin
	update ThanhVien
	set
		Ma_vai_tro = @MaVaiTro,
		Ma_Chi_Nhanh=@MaChiNhanh 
	where id = @MaThanhVien
	END
END